﻿using System;

namespace SBPweb.PROvibe.Business.Shared.Contracts.Content
{

    public struct TypeDescriptor
    {

        public TypeDescriptor(string xapPath, string asmPath, string typeName)
        {
            XapPath = xapPath;
            AssemblyPath = asmPath;
            FullyQualifiedTypeName = typeName;
        }

        public string XapPath;

        public string AssemblyPath;

        public string FullyQualifiedTypeName;

        public override string ToString()
        {
            return string.Format("/{0}/{1};{2}", XapPath, AssemblyPath, FullyQualifiedTypeName);
        }

        public static TypeDescriptor? GetDescriptorByPath(string description)
        {
            string[] split = description.Split(new char[] { '/', ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length < 3)
            {
                return null;
            }

            return new TypeDescriptor(split[0], split[1], split[2]);
        }

    }

}
